package cn.xclink.common.util;

import java.util.ArrayList;
import java.util.List;
import cn.xclink.business.entity.MonthEntity;
import cn.xclink.common.entity.ConnomCount;
public class DateUtil {
	/**
	 * 
	 * @param month 
	 * @param year
	 * @return
	 */

	public static List<ConnomCount> toJson(MonthEntity month,String year){
		List<ConnomCount> list= new ArrayList<>();
		//1 创建12个对象
		for (int i = 0; i < 12; i++) {	
			ConnomCount connomCount =new ConnomCount();
			connomCount.setYear(Integer.valueOf(year));
			connomCount.setMonth(i+1);
			list.add(connomCount);
		}
		//分别开始赋值
		if(month!=null){
			list.get(0).setCount(month.getJanNumber());
			list.get(1).setCount(month.getFebNumber());
			list.get(2).setCount(month.getMarNumber());
			list.get(3).setCount(month.getAprNumber());
			list.get(4).setCount(month.getMayNumber());
			list.get(5).setCount(month.getJunNumber());
			list.get(6).setCount(month.getJulNumber());
			list.get(7).setCount(month.getAugNumber());
			list.get(8).setCount(month.getSepNumber());
			list.get(9).setCount(month.getOctNumber());
			list.get(10).setCount(month.getNovNumber());
			list.get(11).setCount(month.getDecNumber());
		}else {
			list.get(0).setCount(0l);
			list.get(1).setCount(0l);
			list.get(2).setCount(0l);
			list.get(3).setCount(0l);
			list.get(4).setCount(0l);
			list.get(5).setCount(0l);
			list.get(6).setCount(0l);
			list.get(7).setCount(0l);
			list.get(8).setCount(0l);
			list.get(9).setCount(0l);
			list.get(10).setCount(0l);
			list.get(11).setCount(0l);
		}
		return list;
	}
}
